/*cnpm install express --save*/
var express=require('express');//导入express(http框架)
var app=new express();//实例化express
var url=require('url')

var requestTime=function(req,res,next){
    var visitedDate=new Date();
    req.requestTime=visitedDate.getFullYear().toString()+"-"
        +(visitedDate.getMonth()+1).toString()+"-"+visitedDate.getDate().toString()
     next();
}

app.use(requestTime);

app.get('/login',function (req,res) {
    console.log("request time is:"+req.requestTime);
    res.send('login');
})

app.get('/index',function (req,res) {

    console.log("request time is:"+req.requestTime);
    res.send('index');
})

var server = app.listen(3000,'localhost',function () {

    var host = server.address().address;
    var port = server.address().port;

    console.log("这个服务的访问地址是 http://%s:%s",host, port);
})// 通过监听
